import javax.swing.*;

public class DisplayRunnable implements Runnable{
    private JLabel labFloor;
    private JLabel labStatus;
    private JLabel labCountPeople;
    private HElevator elevator;

    public DisplayRunnable(HElevator elevator, JLabel labFloor,JLabel labCountPeople, JLabel labStatus){

        this.labFloor = labFloor;
        this.labStatus = labStatus;
        this.labCountPeople = labCountPeople;
        this.elevator = elevator;
    }

    public void run(){
        String status = "";

        while(true){
            switch(elevator.getDirection()) {
                case HElevator.UP :
                    status = "向 上";
                    break;
                case HElevator.DOWN :
                    status = "向 下";
                    break;
                default:
                    status = "--";
            }

            labStatus.setText("          "+status);
            labFloor.setText("        第" + elevator.getCurrentFloor()+"层");
            labCountPeople.setText("   电梯内"+elevator.getCountPeople()+"个人");
        }
    }
}
